package ncu.me.musicplayer.sql;

import java.util.List;

import ncu.me.musicplayer.MyApplication;
import ncu.me.musicplayer.entity.MusicInfo;
import ncu.me.musicplayer.entity.MusicInfoDao;

/**
 * @Author ye
 * @Date 2020/6/2 16:10
 * @Version 1.0
 */
public class MusicDao {
    MusicInfoDao mDao;
    private MusicDao(){
        mDao = MyApplication.sDaoSession.getMusicInfoDao();
    }
    public static MusicDao getInstance(){return Holder.instance;}
    static class Holder{
        static MusicDao instance = new MusicDao();
    }
    public List<MusicInfo> getAll(){
        return mDao.queryBuilder().build().list();
    }
    public MusicInfo get(String mid){
        return mDao.queryBuilder().where(MusicInfoDao.Properties.Mid.eq(mid)).unique();
    }
    public void update(MusicInfo info){
        mDao.update(info);
    }
    public void insert(MusicInfo info){
        mDao.save(info);
    }
    public void delete(MusicInfo info){
        mDao.delete(info);
    }
}
